package com.lzh.shijicloudstack.controller;

import com.lzh.shijicloudstack.common.R;
import com.lzh.shijicloudstack.common.ResultUtil;
import com.lzh.shijicloudstack.model.dto.menu.MenuPageDto;
import com.lzh.shijicloudstack.model.entity.Menu;
import com.lzh.shijicloudstack.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 菜单权限 控制器
 *
 * @author luzhiheng
 * @date 2025/4/24
 */
@Api(tags = "菜单权限模块")
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    @ApiOperation(value = "删除")
    @PostMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Long id) {
        return ResultUtil.success(menuService.delete(id));
    }

    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public R<Boolean> updateMenu(@RequestBody Menu menu) {
        return ResultUtil.success(menuService.updateMenu(menu));
    }

    @ApiOperation(value = "分页查询")
    @PostMapping("/pageList")
    public R<Map<String, Object>> pageList(@RequestBody MenuPageDto dto) {
        return ResultUtil.success(menuService.pageList(dto));
    }
}
